package com.atguigu.lease.web.admin.controller.apartment;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.model.entity.PaymentType;
import com.atguigu.lease.web.admin.service.PaymentTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author = 赵子涵
 * @date = 2025/4/30 16:11
 * @function =
 */
@RestController
@Tag(name = "支付方式管理")
@RequestMapping("/admin/payment")
public class PaymentTypeController {
    @Autowired
    PaymentTypeService paymentTypeService;
    @GetMapping("/list")
    @Operation(summary = "查询全部支付方式列表")
    public Result listAll(){
        List<PaymentType> list = paymentTypeService.list();
        return Result.ok(list);
    }
    @PostMapping("/saveOrUpdate")
    @Operation(summary = "保存或更新支付方式")
    public Result saveOrUpdate(@RequestBody PaymentType paymentType){
        paymentTypeService.saveOrUpdate(paymentType);
        return Result.ok();
    }
    @DeleteMapping("/deleteById")
    @Operation(summary = "根据ID删除支付方式")
    public Result delete(@RequestParam Long id){
        paymentTypeService.removeById(id);
        return Result.ok();
    }
}
